package com.notecalendar.exception;

import java.util.HashMap;
import java.util.Map;

public class EvernoteBeanException extends Exception {
	//Exceptions codes
	public final static int GENERAL_EXCEPTION = 0;
	public final static int CAN_NOT_INITIALIZED_EXCEPTION = 1;
	public final static int NOT_INITIALIZED_EXCEPTION = 2;
	public final static int CAN_NOT_GET_NOTES_EXCEPTION = 3;
	public final static int CREATE_NOTE_EXCEPTION = 4;
	public final static int CREATE_EMAIL_NOTE = 5;
	
	//Exception descriptions
	public final static String GENERAL_EXCEPTION_DESC = "System Error";
	public final static String CAN_NOT_INITIALIZED_EXCEPTION_DESC = "Login on evernote system fails";
	public final static String NOT_INITIALIZED_EXCEPTION_DESC = "The evernote system must be intitializated."+
		" Call method \"evernoteSystemInit\" first.";
	public final static String CAN_NOT_GET_NOTES_EXCEPTION_DESC = "Error getting back notes";
	public final static String CREATE_NOTE_EXCEPTION_DESC = "Error creating a note";
	public final static String CREATE_EMAIL_NOTE_DES = "Error sending a note by email";
	
	//Exceptions Map
	private final static Map<Integer, String> EXCEPTIONS_MAP = new HashMap<Integer, String>();
	{
		EXCEPTIONS_MAP.put(new Integer(GENERAL_EXCEPTION), GENERAL_EXCEPTION_DESC);
		EXCEPTIONS_MAP.put(new Integer(CAN_NOT_INITIALIZED_EXCEPTION), CAN_NOT_INITIALIZED_EXCEPTION_DESC);
		EXCEPTIONS_MAP.put(new Integer(NOT_INITIALIZED_EXCEPTION), NOT_INITIALIZED_EXCEPTION_DESC);
		EXCEPTIONS_MAP.put(new Integer(CAN_NOT_GET_NOTES_EXCEPTION), CAN_NOT_GET_NOTES_EXCEPTION_DESC);
		EXCEPTIONS_MAP.put(new Integer(CREATE_NOTE_EXCEPTION),CREATE_NOTE_EXCEPTION_DESC);
		EXCEPTIONS_MAP.put(new Integer(CREATE_EMAIL_NOTE),CREATE_EMAIL_NOTE_DES);
	}
	
	
	private int type = GENERAL_EXCEPTION;
	private String typeDesc = GENERAL_EXCEPTION_DESC;
	
	public EvernoteBeanException(){
	}
	
	public EvernoteBeanException(int type){
		setType(type);
		setTypeDesc(EXCEPTIONS_MAP.get(type));
	}
	
	
	
	private void setType(int type) {
		this.type = type;
	}
	public int getType() {
		return type;
	}
	
	private void setTypeDesc(String typeDesc) {
		this.typeDesc = typeDesc;
	}
	public String getTypeDesc() {
		return typeDesc;
	}
}
